﻿using Ace.IdStrategy;
using Chloe.Admin.Common.Tree;
using Chloe.Application.Interfaces;
using Chloe.Application.Models.Activity;
using Chloe.Entities;
using Chloe.Admin.Common;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Chloe.Application.Interfaces.Bike;
using Ace;

namespace Chloe.Admin.Areas.BikeClub.Controllers
{
    [LoginAuthorizeAttribute]
    public class ActivityController : WebController
    {
        // GET: BikeClub/Activity
        public ActionResult Index()
        {
            List<SelectOption> activitynameList = SelectOption.CreateList(this.CreateService<IMemberAppService>().GetSimpleModels());

            this.ViewBag.ActivityNameList = activitynameList;
            this.ViewBag.ActivtiyNameListString = JsonHelper.Serialize(activitynameList);

            return View();
        }


        [HttpGet]
        public ActionResult GetModels(string keyword)
        {
            List<Bike_Activity> data = this.CreateService<IActivityAppService>().GetActivitys(keyword);
            return this.SuccessData(data);

            //PagedData<Bike_Activity> pagedData = this.CreateService<IActivityAppService>().GetPageData(pagination, keyword);
            //return this.SuccessData(pagedData);
        }

        [HttpGet]
        public ActionResult GetNames(string keyword)
        {
            List<SelectOption> NameList = SelectOption.CreateList(this.CreateService<IMemberAppService>().GetSimpleModels2());

            return this.SuccessData(NameList);

        }

        [HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult Add(AddActivityInput input)
        {
            this.CreateService<IActivityAppService>().Add(input);
            return this.AddSuccessMsg();
        }

        [HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult Update(UpdateActivityInput input)
        {
            this.CreateService<IActivityAppService>().Update(input);
            return this.UpdateSuccessMsg();
        }

        [HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult Delete(string id)
        {
            this.CreateService<IActivityAppService>().Delete(id);
            return this.DeleteSuccessMsg();
        }
    }
}